package com.gjy.controller;

import com.gjy.comment.AjaxResult;
import com.gjy.controller.domain.Mes161501Request;
import com.gjy.util.QrCodeUtil;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.Map;

/**
 * @author 宫静雨
 * @version 1.0
 * @since 2022-12-29 09:43:51
 */
@Slf4j
@RestController
@RequestMapping("/hello")
public class HelloController {

    @GetMapping("/elk")
    public void elk() {
        log.info("logback的日志信息过来了");
        log.error("logback的错误信息过来了");
    }

    @PostMapping("/valid")
    public AjaxResult valid(@RequestBody @Valid Mes161501Request request) {
        return AjaxResult.ok(request);
    }

    @GetMapping("/kaptcha")
    public AjaxResult kaptcha() {
        // <img src="data:image/jpeg;base64,${imgSrc}" alt="">
        return QrCodeUtil.getCaptcha();
    }

    @GetMapping("/ds")
    public AjaxResult ds(String word) {
        System.out.println("word = " + word);
        return AjaxResult.ok(word);
    }

    @GetMapping("/h1")
    public Object h1(@RequestBody Map<String, Object> map) {
        log.info("{}", map);
        return map;
    }
}
